Skip to content

Add menubar cost/tokens toggle#307

Open
ozymandiashh wants to merge 2 commits into
getagentseal:mainfrom
ozymandiashh:fix-issue-305
Open

Add menubar cost/tokens toggle#307
ozymandiashh wants to merge 2 commits into
getagentseal:mainfrom
ozymandiashh:fix-issue-305

Conversation

@ozymandiashh
Copy link
Copy Markdown
Contributor

@ozymandiashh ozymandiashh commented May 11, 2026

Summary

Fixes #305 by adding a persisted Cost/Tokens toggle to the macOS menubar without changing the existing cost-first workflow.

The important behavior after the latest rebase: Tokens mode now uses CodeBurn's standard token total (inputTokens + outputTokens) for the status item, hero number, chart bars, and Activity rows. Cache read/write token fields are still carried in the payload for cache metadata and future views, but they are not counted in the visible token total. That prevents inflated numbers such as hundreds of millions of cache-read tokens being shown as today's usage.

What changed

  • Add a persisted Cost | Tokens headline metric in the macOS menubar app.
  • Apply the selected metric to:
    • the macOS status item,
    • the popover hero value,
    • the trend chart,
    • Activity row values and bar scaling.
  • Extend menubar-json with input/output/cache read/cache write fields for current period, Activity rows, daily history, and model history.
  • Preserve legacy payload decoding by defaulting newly added cache fields to 0.
  • Store provider-scoped token totals in the daily cache, so provider-filtered views do not fall back to incomplete all-provider numbers.
  • Preserve the current main behavior for per-provider chart history: cached history through yesterday plus fresh parsing for today.
  • Update tests around menubar JSON payloads, daily aggregation, provider-scoped cache fields, and CLI status output.

Example

If today's raw provider data contains:

input:       4.0M
output:      1.9M
cache read: 500M+

Tokens mode displays 5.9M tok, matching the standard CodeBurn visible token total, not 505M+ tok from cache-read traffic.

Validation

  • npx vitest run tests/menubar-json.test.ts tests/day-aggregator.test.ts tests/cli-status-menubar.test.ts tests/daily-cache.test.ts — 43/43 passed.
  • npx tsc --noEmit --pretty false — passed.
  • npm run build — passed.
  • swift build from mac/ — passed.
  • git diff --check — passed.
  • Argus-style local review — PASS.
  • Claude Opus 4.7 effort max review — PASS after fixing the provider-scoped cache path.
  • Gemini 3.1 Pro Preview review — PASS.
  • GitHub checks check, semgrep, and assess — passed.

Notes

No screenshots or raw local usage output are included here. Visual validation was done locally, but project names, prompts, paths, session IDs, exact private usage history, and private product details are intentionally omitted.

@AgentSeal AgentSeal added needs-testing needs-validation PR requires validation against real-world usage before review and removed needs-testing labels May 12, 2026
@ozymandiashh
Copy link
Copy Markdown
Contributor Author

ozymandiashh commented May 17, 2026

Superseded by the later visual validation comment after the token-total fix.

This earlier comment only proved the data/build path:

  • swift build passed.
  • npx vitest run tests/menubar-json.test.ts tests/day-aggregator.test.ts passed.
  • Structural menubar-json checks showed token fields existed.

That was not enough as visual/product proof. The later validation comment replaces it with screenshots and explains the important fix: Tokens mode now uses standard CodeBurn semantics (input + output), not cache read/write buckets, so status item, hero, trend, and Activity rows are consistent.

@ozymandiashh
Copy link
Copy Markdown
Contributor Author

ozymandiashh commented May 17, 2026

Visual validation for #307 after the latest rebase and token-total fix.

Update after contributor review: the earlier screenshot showed inflated token totals because Tokens mode was including cache read/write buckets. That screenshot has been replaced.

Follow-up fix pushed in 85a32fd:

  • Menubar Tokens mode now follows standard CodeBurn usage semantics: input + output tokens only.
  • Cache read/write buckets are still decoded and preserved in the payload for cache metrics/debugging.
  • Status item, hero, trend, and Activity rows now use the same token definition.

CodeBurn menubar status item showing 5.9M tok

CodeBurn menubar popover in Tokens mode showing 5.9M tokens and consistent activity token totals

Validation/proof:

  • npx vitest run tests/menubar-json.test.ts tests/day-aggregator.test.ts - 26/26 tests passed.
  • npm run build - passed.
  • swift build - passed.
  • git diff --check - passed.
  • GitHub checks (assess, check, semgrep) - passed.
  • Argus-style review - PASS.
  • Claude Opus 4.7 effort max review - PASS.
  • Gemini 3.1 Pro Preview review - PASS.

Swift unit tests were not used for the final proof because the current local Swift test target is blocked before filtered tests run by the existing unrelated no such module 'Testing' issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-validation PR requires validation against real-world usage before review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: toggle panel headline between cost and tokens

2 participants